#include <Arduino.h>

String temp;
String str1;

String GPS_rec;
String str_rec;
String UTC, timestamp;
String pos;
void setup()
{
    Serial.begin(115200);
    Serial2.begin(115200);
    Serial.println("start");
}

void loop()
{
    while (Serial2.available())
    {
        delay(10);
        // Serial.println("REC:");
        GPS_rec = Serial2.readStringUntil('*');
        Serial.println(GPS_rec);
        Serial2.readString();
        // temp = Serial2.readString();
    }
    
    if (GPS_rec.length() < 55)
    {
        Serial.println("no pos");
    }
    else if (GPS_rec.length() >= 55)
    {
        Serial.println("get pos");
        UTC = GPS_rec.substring(GPS_rec.indexOf("$GNGNS,"),GPS_rec.indexOf(".00,") );
        pos = GPS_rec.substring(GPS_rec.indexOf(".00,")+4,GPS_rec.indexOf(".00,")+26);
        Serial.println(UTC);
        Serial.println(pos);
    }
    Serial.println("loop");
    delay(500);
}

